/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package deti.es.ukni.persistence.entity;

import java.io.Serializable;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author eurico
 */
@Entity
@Table(name = "COMMENT_VIDEO")
@NamedQueries({@NamedQuery(name = "CommentVideo.findAll", query = "SELECT c FROM CommentVideo c"), @NamedQuery(name = "CommentVideo.findByRefidcomment", query = "SELECT c FROM CommentVideo c WHERE c.commentVideoPK.refidcomment = :refidcomment"), @NamedQuery(name = "CommentVideo.findByRefidaccount", query = "SELECT c FROM CommentVideo c WHERE c.commentVideoPK.refidaccount = :refidaccount"), @NamedQuery(name = "CommentVideo.findByRefidvideo", query = "SELECT c FROM CommentVideo c WHERE c.commentVideoPK.refidvideo = :refidvideo")})
public class CommentVideo implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected CommentVideoPK commentVideoPK;
    @JoinColumn(name = "REFIDACCOUNT", referencedColumnName = "IDACCOUNT", insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.EAGER)
    private Account account;
    @JoinColumn(name = "REFIDCOMMENT", referencedColumnName = "IDCOMMENT", insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.EAGER)
    private Comment comment;
    @JoinColumn(name = "REFIDVIDEO", referencedColumnName = "IDVIDEO", insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.EAGER)
    private Video video;

    public CommentVideo() {
    }

    public CommentVideo(CommentVideoPK commentVideoPK) {
        this.commentVideoPK = commentVideoPK;
    }

    public CommentVideo(int refidcomment, int refidaccount, int refidvideo) {
        this.commentVideoPK = new CommentVideoPK(refidcomment, refidaccount, refidvideo);
    }

    public CommentVideoPK getCommentVideoPK() {
        return commentVideoPK;
    }

    public void setCommentVideoPK(CommentVideoPK commentVideoPK) {
        this.commentVideoPK = commentVideoPK;
    }

    public Account getAccount() {
        return account;
    }

    public void setAccount(Account account) {
        this.account = account;
    }

    public Comment getComment() {
        return comment;
    }

    public void setComment(Comment comment) {
        this.comment = comment;
    }

    public Video getVideo() {
        return video;
    }

    public void setVideo(Video video) {
        this.video = video;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (commentVideoPK != null ? commentVideoPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof CommentVideo)) {
            return false;
        }
        CommentVideo other = (CommentVideo) object;
        if ((this.commentVideoPK == null && other.commentVideoPK != null) || (this.commentVideoPK != null && !this.commentVideoPK.equals(other.commentVideoPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "deti.es.ukni.persistence.entity.CommentVideo[commentVideoPK=" + commentVideoPK + "]";
    }

}
